import {
  getCategory
} from '../../api/categoryApi.js'

export default {
  namespaced: true,
  state: {
    //分类列表
    category_list: [],
    //鼠标略过一级分类ID
    current_category_id: -1,
    //当前分类数据
    cate: {}
  },
  getters: {},
  mutations: {
    //设置分类列表
    set_category_list(state, val) {
      state.category_list = val;
    },
    //设置鼠标略过一级分类ID
    set_current_category_id(state, val) {
      state.current_category_id = val;
    },
    //保存点击的三级分类id
    set_cate(state, val) {
      state.cate = val;
    }
  },
  actions: {
    //获取分类数据
    get_category_list(context) {
      getCategory().then(function(response) {
        if (response.data.httpcode == 200) {
          context.commit('set_category_list', response.data.data)
        }
      })
    }
  }
}
